import { Injectable } from '@angular/core';

@Injectable({
  //  提供给根组件的 服务 被多个组件使用只会创建一个实例
  providedIn: 'root',
})
export class TimeIntervalService {
  constructor() {
    console.log('TimeIntervalService对象被创建');
  }
  start(name: string) {
    console.time(name);
  }
  end(name: string) {
    console.timeEnd(name);
  }
  timeFn(name: string) {
    console.time(name);
    return () => {
      console.timeEnd(name);
    };
  }
}
